package cn.itcast.wushangxiantu.BaseAdapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import cn.itcast.wushangxiantu.Fragment.home.SenLin;
import cn.itcast.wushangxiantu.R;

public class SenLinAdapter extends BaseAdapter {
    private Context context;
    private LayoutInflater layoutInflater;

    public SenLinAdapter(Context context) {
        layoutInflater = LayoutInflater.from(context);
        this.context = context;
    }

    @Override
    public int getCount() {
        return SenLin.getLists().size();
    }

    @Override
    public Object getItem(int i) {
        return SenLin.getLists().get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = layoutInflater.inflate(R.layout.listview_nongyuan, null);
        ViewHolder viewHolder = new ViewHolder(view);
        String content="";
        if (SenLin.getLists().get(i).getStw().equals("OK")){
            content+="【胜利】获得：修为*"+SenLin.getLists().get(i).getJy2()+",";
            if (SenLin.getLists().get(i).getWp().equals("魔核")){
                content+=SenLin.getLists().get(i).getWp()+"*"+SenLin.getLists().get(i).getWpnumber();
            }else{
                content+="【"+SenLin.getLists().get(i).getWp()+"】"+"*"+SenLin.getLists().get(i).getWpnumber();
            }
            if (SenLin.getLists().get(i).getShihun()==1){
                content+=",【石魂】。";
            }
            if (SenLin.getLists().get(i).getMoney()!=0){
                content+=",【金币】*"+SenLin.getLists().get(i).getMoney();
            }
        }else if (SenLin.getLists().get(i).getStw().equals("NO1")){
            content="【失败】敌人太强大了，你毫无还手之力。";
        }else{
            content="【失败】即便是坚持了三十回合，但终究还是挂了。";
        }
        viewHolder.tvWp.setText(content);
        return view;
    }

    class ViewHolder {
        public View rootView;
        public TextView tvWp;

        public ViewHolder(View rootView) {
            this.rootView = rootView;
            this.tvWp = (TextView) rootView.findViewById(R.id.tvWp);
        }

    }
}
